Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
What does "function declarations at the top level" mean?

In this JavaScript documentation, it says:

var statements and function declarations at the top level create properties of the global object. On the other hand, let and const declarations never create properties of the global object.

What does "function declarations at the top level" mean? does it mean functions that are not inner functions?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Top level means not inside other functions or objects or classes or closures. Where this refers to the window object.

console.log(this === window)    // true
var x = 5

function foo() {
  console.log(this === window)    // true
  var y = 3
}

foo.call(this);

console.log(y)    // not defined

about 4 years ago · Santiago Trujillo Relatório

0

What does "function declarations at the top level" mean? Does it mean functions that are not inner functions?

Yes, it means just that. It refers to the syntax of the declarations: anything that is not nested inside some other syntactical structure.

However, the statement is not quite accurate. It should be restricted to the "top level of scripts", since var and function declarations at the top level of module code don't create global variables - they declare variables in the global scope. Also, var declarations in blocks ({ … }) still declare global variables (that become properties of the global object) as long as they're not nested in a function.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda